import request from "@/utils/request";
import { getParamsSuffix } from "@/utils/paramsUtils";

/**
 * 新建
 * @returns {Promise<any>}
 * @param params
 */
export async function create(params) {
  return request("/api/cdcerservice/v1/articleinfo/create", {
    method: "POST",
    requestType: "form",
    data: { ...params }
  });
}

/**
 * 编辑
 * @param params
 * @returns {Promise<any>}
 */
export async function update(params) {
  return request("/api/cdcerservice/v1/articleinfo/update", {
    method: "POST",
    requestType: "form",
    data: { ...params }
  });
}

/**
 * 删除
 * @param params
 * @returns {Promise<any>}
 */
export async function deleteById(params) {
  return request("/api/cdcerservice/v1/articleinfo/deleteById", {
    method: "POST",
    requestType: "form",
    data: { ...params }
  });
}

/**
 * 分页
 * @param query
 * @returns {Promise<any>}
 */
export async function listByPage(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/articleinfo/listByPage?${params}`);
}

/**
 * 获取最新的文章
 * @param query
 * @returns {Promise<any>}
 */
export async function listLatestArticles(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/articleinfo/listLatestArticles?${params}`);
}
